package com.jefe.hudson.service.model.impl;

import com.jefe.hudson.service.model.UserPrefs;
import com.jefe.hudson.service.model.UserPrefsSoap;

import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.HtmlUtil;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.sql.Types;

import java.util.ArrayList;
import java.util.List;


/**
 * <a href="UserPrefsModelImpl.java.html"><b><i>View Source</i></b></a>
 *
 * <p>
 * ServiceBuilder generated this class. Modifications in this class will be
 * overwritten the next time is generated.
 * </p>
 *
 * <p>
 * This class is a model that represents the <code>UserPrefs</code> table
 * in the database.
 * </p>
 *
 * @author Brian Wing Shun Chan
 *
 * @see com.jefe.hudson.service.model.UserPrefs
 * @see com.jefe.hudson.service.model.UserPrefsModel
 * @see com.jefe.hudson.service.model.impl.UserPrefsImpl
 *
 */
public class UserPrefsModelImpl extends BaseModelImpl<UserPrefs> {
    public static final String TABLE_NAME = "UserPrefs";
    public static final Object[][] TABLE_COLUMNS = {
            { "id", new Integer(Types.BIGINT) },
            

            { "hudHost", new Integer(Types.VARCHAR) },
            

            { "hudPort", new Integer(Types.INTEGER) },
            

            { "hudUser", new Integer(Types.VARCHAR) },
            

            { "hudPass", new Integer(Types.VARCHAR) }
        };
    public static final String TABLE_SQL_CREATE = "create table UserPrefs (id LONG not null primary key,hudHost VARCHAR(75) null,hudPort INTEGER,hudUser VARCHAR(75) null,hudPass VARCHAR(75) null)";
    public static final String TABLE_SQL_DROP = "drop table UserPrefs";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.com.jefe.hudson.service.model.UserPrefs"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.com.jefe.hudson.service.model.UserPrefs"),
            true);
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.com.jefe.hudson.service.model.UserPrefs"));
    private long _id;
    private String _hudHost;
    private int _hudPort;
    private String _hudUser;
    private String _hudPass;
    private transient ExpandoBridge _expandoBridge;

    public UserPrefsModelImpl() {
    }

    public static UserPrefs toModel(UserPrefsSoap soapModel) {
        UserPrefs model = new UserPrefsImpl();

        model.setId(soapModel.getId());
        model.setHudHost(soapModel.getHudHost());
        model.setHudPort(soapModel.getHudPort());
        model.setHudUser(soapModel.getHudUser());
        model.setHudPass(soapModel.getHudPass());

        return model;
    }

    public static List<UserPrefs> toModels(UserPrefsSoap[] soapModels) {
        List<UserPrefs> models = new ArrayList<UserPrefs>(soapModels.length);

        for (UserPrefsSoap soapModel : soapModels) {
            models.add(toModel(soapModel));
        }

        return models;
    }

    public long getPrimaryKey() {
        return _id;
    }

    public void setPrimaryKey(long pk) {
        setId(pk);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_id);
    }

    public long getId() {
        return _id;
    }

    public void setId(long id) {
        _id = id;
    }

    public String getHudHost() {
        return GetterUtil.getString(_hudHost);
    }

    public void setHudHost(String hudHost) {
        _hudHost = hudHost;
    }

    public int getHudPort() {
        return _hudPort;
    }

    public void setHudPort(int hudPort) {
        _hudPort = hudPort;
    }

    public String getHudUser() {
        return GetterUtil.getString(_hudUser);
    }

    public void setHudUser(String hudUser) {
        _hudUser = hudUser;
    }

    public String getHudPass() {
        return GetterUtil.getString(_hudPass);
    }

    public void setHudPass(String hudPass) {
        _hudPass = hudPass;
    }

    public UserPrefs toEscapedModel() {
        if (isEscapedModel()) {
            return (UserPrefs) this;
        } else {
            UserPrefs model = new UserPrefsImpl();

            model.setNew(isNew());
            model.setEscapedModel(true);

            model.setId(getId());
            model.setHudHost(HtmlUtil.escape(getHudHost()));
            model.setHudPort(getHudPort());
            model.setHudUser(HtmlUtil.escape(getHudUser()));
            model.setHudPass(HtmlUtil.escape(getHudPass()));

            model = (UserPrefs) Proxy.newProxyInstance(UserPrefs.class.getClassLoader(),
                    new Class[] { UserPrefs.class },
                    new ReadOnlyBeanHandler(model));

            return model;
        }
    }

    public ExpandoBridge getExpandoBridge() {
        if (_expandoBridge == null) {
            _expandoBridge = new ExpandoBridgeImpl(UserPrefs.class.getName(),
                    getPrimaryKey());
        }

        return _expandoBridge;
    }

    public Object clone() {
        UserPrefsImpl clone = new UserPrefsImpl();

        clone.setId(getId());
        clone.setHudHost(getHudHost());
        clone.setHudPort(getHudPort());
        clone.setHudUser(getHudUser());
        clone.setHudPass(getHudPass());

        return clone;
    }

    public int compareTo(UserPrefs userPrefs) {
        long pk = userPrefs.getPrimaryKey();

        if (getPrimaryKey() < pk) {
            return -1;
        } else if (getPrimaryKey() > pk) {
            return 1;
        } else {
            return 0;
        }
    }

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        UserPrefs userPrefs = null;

        try {
            userPrefs = (UserPrefs) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long pk = userPrefs.getPrimaryKey();

        if (getPrimaryKey() == pk) {
            return true;
        } else {
            return false;
        }
    }

    public int hashCode() {
        return (int) getPrimaryKey();
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();

        sb.append("{id=");
        sb.append(getId());
        sb.append(", hudHost=");
        sb.append(getHudHost());
        sb.append(", hudPort=");
        sb.append(getHudPort());
        sb.append(", hudUser=");
        sb.append(getHudUser());
        sb.append(", hudPass=");
        sb.append(getHudPass());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBuilder sb = new StringBuilder();

        sb.append("<model><model-name>");
        sb.append("com.jefe.hudson.service.model.UserPrefs");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>id</column-name><column-value><![CDATA[");
        sb.append(getId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>hudHost</column-name><column-value><![CDATA[");
        sb.append(getHudHost());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>hudPort</column-name><column-value><![CDATA[");
        sb.append(getHudPort());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>hudUser</column-name><column-value><![CDATA[");
        sb.append(getHudUser());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>hudPass</column-name><column-value><![CDATA[");
        sb.append(getHudPass());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
